package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAjaxAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.entity.Car;

/**
 * @author mufeiyu
 */
public class CarStockRegistersStatusAjaxAction extends TmsAjaxAction{
	private Logger logger = Logger.getLogger(CarStockRegistersStatusAjaxAction.class);
	private static final String SERIAL = "serial";

	@Override
	public void process(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws TmsException {
		logger.debug(this.getClass().getName() + "#execute was called.");
		String serial = request.getParameter(SERIAL);
		Car car = Car.getInstance();
		//保存按钮逻辑      
        car = car.findCarBySerial(serial);
		String responseText = "0";
		if(car.getRegisterStatus() == 1){
			responseText = "1";//[U8012]当前车辆的库存状态是“已入库”，不能进行取消操作。
		}else if(car.getBarCodeNum() == 1){
			responseText = "2";//[U8023]当前车辆已经被挂起，不能进行取消操作。
		}
		responseValues(response, responseText, TEXT);
		logger.debug(this.getClass().getName() + "#doAction was completed.");		
	}
}
